local sk_le__qingguo = fk.CreateSkill {

  name = "sk_le__qingguo",

  tags = {},

}



sk_le__qingguo:addEffect(fk.TargetConfirmed, {
  name = "sk_le__qingguo",
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk_le__qingguo.name) and data.from ~= player and
        (data.card.trueName == "slash" or data.card:isCommonTrick()) and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, true, sk_le__qingguo.name, true, ".|.|spade,club|hand",
      "#sk_le__qingguo-discard::" .. data.from.id .. ":" .. data.card:toLogString(), true)
    if #card > 0 then
      event:setCostData(self, card[1])
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(event:getCostData(self), sk_le__qingguo.name, player, player)
    data:cancelTarget(player)
    data.nullified = true
    if player.dead or data.from.dead or Fk:getCardById(event:getCostData(self)).suit ~= Card.Spade then return end
    if room:askForSkillInvoke(player, sk_le__qingguo.name, nil, "#sk_le__qingguo-invoke::" .. data.from.id) then
      room:doIndicate(player.id, { data.from })
      room:loseHp(data.from, 1, sk_le__qingguo.name)
    end
  end,
})

return sk_le__qingguo
